package com.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.entity.Danjingjichu;
import com.example.entity.Danjingxiaoceng;
import com.example.mapper.DanjingMapper;
import com.example.mapper.JichuMapper;
import com.example.service.DanJingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DanJingServiceImpl implements DanJingService {
    @Autowired
    DanjingMapper danjingMapper;
    @Autowired
    JichuMapper jichuMapper;

    @Override
    public Page<Danjingxiaoceng> getAllDanJing(String jh, Integer pagenum, Integer pagesize) {//分页
        QueryWrapper<Danjingxiaoceng> queryWrapper = new QueryWrapper<>();
        Page<Danjingxiaoceng> danjingxiaocengPage = new Page<>(pagenum,pagesize);
        if (!jh.isEmpty()){
            queryWrapper.like(true,"JH",jh);
        }
        return danjingMapper.selectPage(danjingxiaocengPage,queryWrapper);
    }
    @Override
    public Page<Danjingjichu> getALLJiChu(String jh, Integer pagenum, Integer pagesize) {
        QueryWrapper<Danjingjichu> queryWrapper = new QueryWrapper<>();
        Page<Danjingjichu> danjingjichuPage = new Page<>(pagenum,pagesize);
        if (!jh.isEmpty()) {
            queryWrapper.like(true, "JH", jh);
        }
        return jichuMapper.selectPage(danjingjichuPage,queryWrapper);
    }
}
